//初始化函
function init() {
	//document.addEventListener("deviceready", loadRssChannelTemp, true);
	$(document).ready(function(){
		loadConfig_option();
	});
}
function loadConfig_option() {
	//document.addEventListener("backbutton", onBackKeyDown, true);
	var success = function() {
		var data = localStorage;
		//alert(data.autoFlush);
		if (data.autoFlush == "1") {
			$("#autoFlush").attr("checked", true).checkboxradio(
					"refresh");
		}
        if(data.picShow=="1"){
            $("#picShow").attr("checked", true).checkboxradio("refresh"); 
        }

		var index = data.theme.charCodeAt() - 97;
		var myselect = $("select#selectTheme");
		myselect[0].selectedIndex = index;
		myselect.selectmenu("refresh");

		changeTheme(data.theme);
	}
	var error = function(e) {
	}
	//window.plugins.loadConfigAndroid05API.loadconfig(success, error, null);
	loadconfig(success);
}
function loadconfig(success){
	if(localStorage.autoFlush){
	 
	 //localStorage.setItem("autoFlush", "1");
	 
	 success();
	}else{
	   
	   localStorage.setItem("autoFlush", "1");
	}
}
//主题状态修改，将状态写入配置文件中
// option.html中的选择菜单中调用该函数
function themeStateChange(event) {
	var num = event.selectedIndex + 97;
	var themeId = String.fromCharCode(num);
	localStorage.setItem("theme", themeId);
	// 状态修改完成后，再刷新本页面的主题样式
	loadConfig_option();

}
//自动刷新设置改变
function flushStateChange(event) {
	// alert(event.checked);
	if (event.checked) {
		localStorage.setItem("autoFlush", 1);
	} else {
		localStorage.setItem("autoFlush", 0);
	}

}
//显示图片设置改变
function picStateChange(event) {
	// alert(event.checked);
	if (event.checked) {
		localStorage.setItem("picShow", 1);
	} else {
		localStorage.setItem("picShow", 0);
	}
    
}